//component promise  component.then(res=>{})
import React, {PureComponent} from "react";

export default function LoadAble(component) {
  return class extends PureComponent {
    state = {
      Template: null
    };

    render() {
      const {Template} = this.state;
      {
        return !Template ? null : <Template {...this.props}/>
      }
    }

    async componentDidMount() {
      // console.log(component);
      // import
      let module = await component();
      this.setState({
        Template: module.default// 组件
      })
    }
  }
}
